package com.example.demo.controller;

import com.example.demo.entity.Student;
import com.example.demo.service.DatabaseService;
import com.example.demo.service.StudentService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author zhouzq1@chinaexpressair.com
 * @title
 * @date 2021/4/26 16:45
 **/
@RestController
@RequestMapping(value = "/index")
public class IndexController {
    @Autowired
    private StudentService studentService;

    @Autowired
    private DatabaseService databaseService;

    @RequestMapping(value = "/query")
    public Student queryById(Integer id){
        Student cost = new Student();

        /*DataSourceConfig otherDataSourceEntity = databaseService.findByName(datasourceName);
        if(otherDataSourceEntity!=null){
            DynamicDataSourceUtil.generateDynamicDataSource(otherDataSourceEntity);
        }*/
        cost = studentService.query1(id);
        return cost;
    }

    @RequestMapping(value = "/page")
    public PageInfo<Student> queryPage(){
        return studentService.queryPage();
    }
}
